{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="get"  class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-block" style="margin-left: 0px">
                        <input type="text" name="title" value="{$Request.get.title}" placeholder="请输入奖品标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <input type="hidden" name="shang_id"  value="{$shang_id}">
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin mmm" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>

        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" onclick="card_goodslist_add({$shang_id})" >添加奖品</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table" style="text-align:center">
                <thead>
                <tr>
                    <th>奖品名称</th>
                    <th>奖品图片</th>
                    <th>奖品售价</th>
                    <th>奖品兑换价</th>
                    <th>奖品数量</th>
                    <th>等级内概率({$real_pro}%)</th>
                    <th>奖赏类型</th>
                    <th>预售时间</th>
                    <th>排序</th>
                    <!--<th>赠送编号</th>-->
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                <tr>
                    <td>{$vo['title']}</td>
                    <td><img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;"></td>
                    <td>{$vo['price']}</td>
                    <td>{$vo['money']}</td>
                    <td>{$vo['special_stock']}</td>
                    <td>{$vo['real_pro']}%</td>
                    <td>
                        <button class="layui-btn layui-btn-info layui-btn-radius layui-btn-sm">{$vo['shang']}</button>
                    </td>
                    <td>{$vo.sale_time}</td>
                    <td>{$vo['sort']}</td>
                    <!--<td style="text-align: left">{$vo['card_no']}</td>-->
                    <td>
                        <a style="text-decoration:none" title="编辑" onclick="card_goodslist_edit({$vo['id']})"  class="layui-btn layui-btn-radius layui-btn-normal layui-btn-xs">
                            <i class="layui-icon layui-icon-edit"></i>编辑
                        </a>
                        <a style="text-decoration:none" title="删除" onClick="card_del({$vo.id})" class="layui-btn layui-btn-danger layui-btn-radius layui-btn-xs">删除</a>

                    </td>
                </tr>
                {/volist}

                {if condition="empty($list)"}
                <tr><td colspan='10' style="text-align:center;">暂时没有数据！</td></tr>
                {/if}
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['layer','table'], function(){
        var $ = layui.$;
        
    })

    //添加奖品
    function card_goodslist_add(shang_id) {
        var url  = "{:url('/admin/card_goodslist_add?card_id="+shang_id+"')}";
        layer.open({
            type: 2,
            title: '添加奖品',
            shadeClose: false,
            shade: 0.3,
            area: ['95%', '95%'],
            content: url,
        });
    }

    //编辑奖品
    function card_goodslist_edit(id) {
        var url  = "{:url('/admin/card_goodslist_edit?id="+id+"')}";
        layer.open({
            type: 2,
            title: '编辑奖品',
            shadeClose: false,
            shade: 0.3,
            area: ['95%', '95%'],
            content: url,
        });
    }

    
    //上下架
    function card_del(id){
        var title = "删除";
        layer.confirm('确认要执行'+title+'操作吗？',function(){
            var url = "{:url('/admin/card_goodslist_del')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id},function(data){
                if(data.status == 1){
                    layer.msg(title+'成功',{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1000},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }
</script>
</body>
</html>


